fix(events): collapse unauthorized-agent list to 404#290
Closed
asherfink wants to merge 1 commit into
Closed
Conversation
The list_events route gates on the parent agent via DAuthorizedQuery, which collapses a denied agent check to 404 — consistent with the other agent-gated routes — so the events filter can't be used to probe cross-tenant agent existence. Align the integration test, which still asserted 403, with this behavior.
danielmillerp
approved these changes
Jun 9, 2026
declan-scale
approved these changes
Jun 9, 2026
Contributor
Author
|
Nvm this was already fixed in #291 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
GET /eventsgates on the parent agent viaDAuthorizedQuery, which collapses a denied agent check to 404 — consistent with the other agent-gated routes — so the events filter can't be used to probe cross-tenant agent existence. The integration test still asserted 403; this aligns it with that behavior.Test
tests/integration/api/events/test_events_authz_api.py::TestEventsAuthzAPIIntegration::test_list_events_unauthorized_agent_returns_404(renamed from_returns_403) — passes locally alongside the rest of the events authz suite.Greptile Summary
This PR corrects a stale integration test that was asserting a 403 response for an unauthorized-agent query on
GET /events, when the production code already collapses that denial to 404 viaDAuthorizedQuery→_check_agent_or_collapse_to_404.test_list_events_unauthorized_agent_returns_403→_returns_404and updates theassert response.status_codefrom403to404.Confidence Score: 5/5
Safe to merge — the single changed test now correctly reflects the 404 behavior already enforced by the production authorization helper.
The fix is confined to one test assertion. The production path through DAuthorizedQuery → _check_agent_or_collapse_to_404 has been returning 404 for denied agents, so updating the test to match closes a gap where the test was silently not exercising the real behavior.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant EventsRouter as GET /events participant DAuthorizedQuery participant CheckAgent as _check_agent_or_collapse_to_404 participant AuthService as AuthorizationService participant Exception as ItemDoesNotExist (404) Client->>EventsRouter: "GET /events?task_id=X&agent_id=Y" EventsRouter->>DAuthorizedQuery: resolve agent_id dependency DAuthorizedQuery->>CheckAgent: check agent Y (read) CheckAgent->>AuthService: authorization.check(agent Y, read) AuthService-->>CheckAgent: AuthorizationError (denied) CheckAgent->>Exception: raise ItemDoesNotExist Exception-->>Client: HTTP 404Reviews (1): Last reviewed commit: "fix(events): collapse unauthorized-agent..." | Re-trigger Greptile